home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / basic / ace24dist.lha / ace24.lha / utils / ab2ascii-1.3 / flist.c < prev    next >
C/C++ Source or Header  |  1996-09-11  |  2KB  |  92 lines

  1. /*
  2.  *  FLIST.C
  3.  */
  4.  
  5. /*
  6.  * (c)Copyright 1994 by Tobias Ferber.
  7.  *
  8.  * This file is part of AmigaBASIC->ASCII.
  9.  *
  10.  * AmigaBASIC->ASCII is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License as
  12.  * published by the Free Software Foundation; either version 1 of the
  13.  * License, or (at your option) any later version.
  14.  *
  15.  * AmigaBASIC->ASCII is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with AmigaBASIC->ASCII; see the file COPYING.  If not, write to
  22.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. #include <ctype.h>
  26. #include <stdlib.h>
  27.  
  28. typedef struct fnode
  29. {
  30.   struct fnode *next;
  31.   char *filename;
  32.  
  33. } fnode_t;
  34.  
  35. static fnode_t *flist= (fnode_t *)0L;
  36.  
  37.  
  38. int
  39. chain_fname(fname)
  40. char *fname;
  41. {
  42.   static fnode_t *tail= (fnode_t *)0L;
  43.  
  44.   fnode_t *fn= (fnode_t *)malloc( sizeof(fnode_t) );
  45.  
  46.   if( fn )
  47.   {
  48.     fn->filename= fname;
  49.     fn->next= (fnode_t *)0L;
  50.  
  51.     if(!flist)
  52.        flist= fn;
  53.  
  54.     if(tail)
  55.       tail->next= fn;
  56.  
  57.     tail= fn;
  58.   }
  59.  
  60.   return fn ? 0:1;
  61. }
  62.  
  63.  
  64. char *
  65. unchain_fname( void )
  66. {
  67.   char *fname= (char *)0L;
  68.  
  69.   if(flist)
  70.   {
  71.     fnode_t *fn= flist;
  72.     flist= flist->next;
  73.  
  74.     fname= fn->filename;
  75.     free(fn);
  76.   }
  77.  
  78.   return fname;
  79. }
  80.  
  81.  
  82. void
  83. purge_flist( void )
  84. {
  85.   while(flist)
  86.   {
  87.     fnode_t *fn= flist;
  88.     flist= flist->next;
  89.     free(fn);
  90.   }
  91. }
  92.